function * fn () {
    yield 1;
    yield 2;
    return 'end';  
}

for (let i of fn()) {
    console.log(i)
}

// 1
// 2